home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / BARNET / ARMTEX / SOURCES1 / !TeX / texmf / source / armTeX / Extras / c / fcat next >
Encoding:
Text File  |  1998-03-19  |  720 b   |  44 lines

  1. /*
  2.  * fcat.c --- concatenate files to stdout
  3.  */
  4.  
  5. /*
  6.  * Synopsis fcat infile1 infile2 ...
  7.  */
  8.  
  9. #include <stdio.h>
  10.  
  11. #define BSIZE 0x10000
  12.  
  13. void
  14. typefile(char *name)
  15. {
  16.   static char     buffer[BSIZE];
  17.   int             bytes;
  18.   FILE           *file;
  19.  
  20.   file = fopen(name, "r");
  21.   if (!file) {
  22.     fprintf(stderr, "fcat: cannot open inputfile '%s'\n", name);
  23.     return;
  24.   }
  25.   while (!feof(file)) {
  26.     bytes = fread(buffer, 1, BSIZE, file);
  27.     fwrite(buffer, 1, bytes, stdout);
  28.   }
  29.   fclose(file);
  30. }
  31.  
  32. int
  33. main(int argc, char *argv[])
  34. {
  35.   int             arg;
  36.  
  37.   if (argc <= 1) {
  38.     fprintf(stderr, "Usage : %s file1 file2 ...\n", argv[0]);
  39.     return 1;
  40.   }
  41.   for (arg = 1; arg < argc; arg++)
  42.     typefile(argv[arg]);
  43. }
  44.